#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int n, m;
const int maxn = 3e5 + 10;
int maxr = 0x3f3f3f3f;

int r[maxn], k[maxn];
int minpos[maxn];

int ans = 0;

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> r[i];
    }
    for (int i = 1; i <= m; i++)
    {
        cin >> k[i];
    }
    int lastpos = n;
    minpos[1] = r[1];
    for (int i = 2; i <= n; i++)
    {
        minpos[i] = min(minpos[i - 1], r[i]);
    }
    for (int i = 1; i <= m; i++)
    {
        while (k[i] > minpos[lastpos])
        {
            lastpos--;
        }
        lastpos--; //表示当前位置已经占用，所以下次开始要从上一个开始
        if (lastpos <= 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << lastpos + 1 << endl; //减去多减小的量即可
   // system("pause");
    return 0;
}